package cn.zwk.entity;

import lombok.Data;

import java.util.List;

@Data
public class MetricList {
    private Snapshoot parent;
    private String annotation;
    private String name;
    private String type;
    private List<AbstractItem> items;
    
    // 添加便捷方法来设置双向关联
    public void setItems(List<AbstractItem> items) {
        this.items = items;
        if (items != null) {
            for (AbstractItem item : items) {
                item.setParent(this);
            }
        }
    }
    
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        if (annotation != null && !annotation.isEmpty()) {
            sb.append(annotation);
        }
//        sb.append("# TYPE ").append(name).append(" ").append(type).append("\n");
        if (items != null) {
            for (AbstractItem item : items) {
                sb.append(item.toString()).append("\n");
            }
        }
        return sb.toString();
    }
}
